<template>
  <div class="header">
    <div class="headLeft">
      <Svgview ion="#icon-31liebiao" @click="menu" />
    </div>
    <div class="headCenter">
      <van-search v-model="searValue" shape="round" background="rgb(254,250,250)" :placeholder="defVal"
        @click="search" />
    </div>
    <div class="headRight">
      <Svgview ion="#icon-yinlechangpian" />
    </div>
    <van-popup v-model:show="menuShow" position="left" :style="{ width: '80%', height: '100%' }" teleport="body">
      <MenuLeft />
    </van-popup>
  </div>
</template>

<script setup>
import { ref, onMounted } from "vue";
import { getDefultSearch } from "@/assets/axios/api";
import { useRouter } from "vue-router";
import Svgview from "@/components/SvgView";
import MenuLeft from "../../components/MenuLeft.vue";
const searValue = ref(""); //搜索值
const defVal = ref(""); //搜索框默认值
const menuShow = ref(false)//菜单显示
const router = useRouter()
const search = () => {
  router.push('/search')
}
onMounted(async () => {
  //获得默认搜索提示
  let response = await getDefultSearch();
  defVal.value = response.data.data.showKeyword;
});
const menu = () => {
  menuShow.value = true
}
</script>

<style scoped lang="less">
.header {
  background-color: white;
  display: flex;
  justify-content: space-between;
  justify-items: center;
  height: 50px;
  width: 100%;
  padding: 10px;
  position: fixed;
  z-index: 1;

  .headLeft {
    line-height: 40px;

    .icon {
      width: 20px;
      height: 20px;
    }
  }

  .headCenter {
    display: flex;
    justify-items: center;

    .van-search {
      padding: 0;
      width: 290px;
    }
  }

  .headRight {
    line-height: 40px;

    .icon {
      width: 20px;
      height: 20px;
    }
  }
}
</style>
